home *** CD-ROM | disk | FTP | other *** search
- Path: silver.sdsmt.edu!not-for-mail
- From: kbs3387@silver.sdsmt.edu (Kevin Stone)
- Newsgroups: comp.lang.c,comp.graphics.algorithms,rec.games.programmer
- Subject: Re: Speed question here...
- Followup-To: comp.lang.c,comp.graphics.algorithms,rec.games.programmer
- Date: 15 Feb 1996 17:59:07 GMT
- Organization: South Dakota School of Mines and Technology
- Distribution: world
- Message-ID: <4fvs9b$s4l@news.sdsmt.edu>
- References: <4ftluh$1gkv@hearst.cac.psu.edu>
- NNTP-Posting-Host: silver.sdsmt.edu
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- : I was curious as to how fast something like the
- : following would execute:
- :
- : int x;
- : node *ptr; ptr in linked list
- :
- : for ( ptr = first_node; ptr != NULL; ptr = ptr.next ) {
- : for ( x = 0; x < max; x++ ) {
- : array[x] = array_other[x];
- : }
- : }
- :
- : I really am not interested in the assignment statement, that's easy.
- : but the traversal through the linked list, and inner integer incremental
- : for loop for each node visited. How fast is a traversal through
- : a linked list when you do a for loop at each node?
-
- The time complexity for this code is O(nodes * max), which could
- almost be stated as O(n^2).
-
- Speed is such a subjective issue. Code alone won't tell you crap
- about how fast it will execute, apart from determining time
- complexities.
-
- You should state what computer and what compiler your using, since both
- play a vital role.
-
- BAS
-
-